class Solution
{
public:
    vector<string> buildArray(vector<int> &target, int n)
    {
        vector<string> result;
        int curNum = 1;
        for (int targetNum : target)
        {
            while (true)
            {
                result.push_back("Push");
                if (curNum++ != targetNum)
                {
                    result.push_back("Pop");
                }
                else
                {
                    break;
                }
            }
        }
        return result;
    }
};